<?php
defined('_JEXEC') or die( ); 
JHTML::_('behavior.tooltip'); 
 
$listOrder	= @$this->lists['order'];
$listDirn	= @$this->lists['order_Dir'];
$saveOrder	= $listOrder == 'c.ordering';
$user = &JFactory::getUser();
?>

<script type="text/javascript">
function submitform(pressbutton)
{
	var form = document.adminForm;
   	if (pressbutton)
    {form.task.value=pressbutton;}

	if ((pressbutton=='add')||(pressbutton=='remove'))
	{
	  	form.controller.value="exchange" ;
	}
	try 
	{
		form.onsubmit();
	}
	catch(e){}
	form.submit();
}
</script>
<form id="adminForm"  action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" >
    <?php if (!empty( $this->sidebar)) : ?>
	<div id="j-sidebar-container" class="span2">
		<?php echo $this->sidebar; ?>
	</div>
	<div id="j-main-container" class="span10">
	<?php else : ?>
		<div id="j-main-container">
	<?php endif;?>
		<br clear="all">	
    	<div id="filter-bar" class="btn-toolbar">
		<div class="filter-search btn-group pull-left fltlft">
			<label for="filter_search" class="element-invisible">Search</label>
			<input type="text" name="search" id="search" 
			placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" 
			value="<?php echo $this->search ?>"  title="" />
		</div>		
		<div class="filter-search btn-group pull-left fltlft">
			<button type="submit" class="btn"><i class="icon-search"></i></button>
			<button type="button" class="btn" onclick="document.id('search').value=''; this.form.submit();"><i class="icon-remove"></i></button>
		</div>
		<div class="btn-group pull-right hidden-phone fltrt">
			
		</div>
	</div>
	<br clear="all">
    <div id="editcell">
		<table class="table table-striped adminlist">
		<thead>
			<tr>
				<th width="20">
					<?php echo JHtml::_('grid.checkall'); ?>
				</th>
				<th width="20">
                	<?php echo JHTML::_('grid.sort',  'Id', 'e.id', $listDirn, $listOrder ); ?>
               	</th>
				<th class="title" width="20%">
                	<?php echo JHTML::_('grid.sort',  'Member', 'u.name', $listDirn, $listOrder ); ?>
               	</th>
                <th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Member Id', 'pro.member_id',$listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Type', 'e.type',$listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Point', 'e.point',$listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Remain', 'e.point',$listDirn, $listOrder ); ?>
				</th>
				
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Created By', 'e.created_id',$listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Created Date', 'e.created_date',$listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Modify By', 'e.modify_id',$listDirn, $listOrder ); ?>
				</th>
				<th nowrap="nowrap">
				   	<?php echo JHTML::_('grid.sort',  'Modify Date', 'e.modify_date',$listDirn, $listOrder ); ?>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
           $k = 0;
			for ($i=0, $n= count( $this->items ); $i < $n; $i++):
				$ordering	= ($listOrder == 'c.ordering');
				$row = &$this->items[$i];
				$checked 	= JHTML::_('grid.checkedout',   $row, $i);
	            $canChange	= $user->authorise('core.edit.state', 'com_wrd.exchange.'.$row->id);
				$published 	= JHTML::_('jgrid.published', $row->published, $i,'exchange.', $canChange,'cb');
				if($row->point > 0):
		?>
				<tr class="<?php echo "row$k"; ?>"  >
	                <td>
						<?php echo $checked; ?>
					</td>
					<td>
						<?php echo $row->id;; ?>
					</td>
	                <td>
		                <?php 
		                	if(empty($this->user_info[$row->user_id]->f_name) && empty($this->user_info[$row->user_id]->l_name)){
		                		$u_name = $row->user_name ; 
		                	}else{
		                		$u_name = $this->user_info[$row->user_id]->l_name.' '.$this->user_info[$row->user_id]->f_name ;
		                	}
		                ?>
						<a href='index.php?option=com_wrd&controller=profile&id=<?php echo $this->user_info[$row->user_id]->id ; ?>&layout=form'>
							<img src="<?php echo JURI::base().'components/com_wrd/assets/images/details.png' ?>" title='Profile of <?php echo $u_name ; ?>' alt='Profile of <?php echo $u_name ; ?>' />
						</a>
				 		<a href="index.php?option=com_wrd&controller=exchange&id=<?php echo $row->id ?>&layout=form"> <?php echo $u_name ; ?> </a>
					</td>
					<td>
						<?php echo $row->member_id ; ?>
					</td>
					<td>
						<?php 
							switch($row->type){
					 			case 0 : 
					 				echo "transaction" ;
					 				break;
				 				case 1 : 
									echo "registration"	;	 				
					 				break;
					 			case 2 : 
					 				echo "add point by hand" ;
					 				break;
				 				case 3 : 
					 				echo "banner click" ;
					 				break;
					 		}
						?>
					</td>
					<td>
						<?php echo $row->point; ?>
					</td>
					<td>
						<?php echo $row->point; ?>
					</td>
					
					<td>
						<?php echo $row->created_user ; ?>
					</td>
					<td>
						<?php echo $row->created_date ; ?>
					</td>
					<td>
						<?php echo $row->modify_user ; ?>
					</td>
					<td>
						<?php echo $row->modify_date ; ?>
					</td>
				</tr>
		<?php
					endif;
	            $k = 1 - $k ;
			endfor ;
		?>
		</tbody>

		<tfoot>
			<tr>
				<td colspan="16">
                    <?php
                         echo $this->pagination->getListFooter();
                    ?>
                </td>
			</tr>
		</tfoot>
		</table>
	</div>

	<input type="hidden" name="controller" value="exchange" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>